QuickOPC User's Guide and Reference
GetMultiplePropertyValues(IEasyDAClient,String,String,String,DAPropertyId[]) Method
Example 



OpcLabs.EasyOpcClassic Assembly > OpcLabs.EasyOpc.DataAccess Namespace > IEasyDAClientExtension Class > GetMultiplePropertyValues Method : GetMultiplePropertyValues(IEasyDAClient,String,String,String,DAPropertyId[]) Method
The client object that will perform the operation.
Name of the machine. Determines the computer on which the OPC server is located. May be an empty string, in which case the OPC server is assumed to exist on the local computer or at the computer specified for it by DCOM configuration.
Contains ProgID of the OPC server to read from.
The Item ID of the OPC item involved in the operation.
Array of Property IDs being obtained
Gets values of multiple OPC properties of a specified OPC item. Gets values of multiple OPC properties, using individual parameters specifying the OPC server, and OPC Item ID.
Syntax
'Declaration
 
<ExtensionAttribute()>
<ElementsNotNullAttribute()>
<NotNullAttribute()>
Public Overloads Shared Function GetMultiplePropertyValues( _
   ByVal client As IEasyDAClient, _
   ByVal machineName As String, _
   ByVal serverClass As String, _
   ByVal itemId As String, _
   ByVal propertyIdArray() As DAPropertyId _
) As ValueResult()
'Usage
 
Dim client As IEasyDAClient
Dim machineName As String
Dim serverClass As String
Dim itemId As String
Dim propertyIdArray() As DAPropertyId
Dim value() As ValueResult
 
value = IEasyDAClientExtension.GetMultiplePropertyValues(client, machineName, serverClass, itemId, propertyIdArray)
[Extension()]
[ElementsNotNull()]
[NotNull()]
public static ValueResult[] GetMultiplePropertyValues( 
   IEasyDAClient client,
   string machineName,
   string serverClass,
   string itemId,
   DAPropertyId[] propertyIdArray
)
[Extension()]
[ElementsNotNull()]
[NotNull()]
public:
static array<ValueResult^>^ GetMultiplePropertyValues( 
   IEasyDAClient^ client,
   String^ machineName,
   String^ serverClass,
   String^ itemId,
   array<DAPropertyId^>^ propertyIdArray
) 

Parameters

client
The client object that will perform the operation.
machineName
Name of the machine. Determines the computer on which the OPC server is located. May be an empty string, in which case the OPC server is assumed to exist on the local computer or at the computer specified for it by DCOM configuration.
serverClass
Contains ProgID of the OPC server to read from.
itemId
The Item ID of the OPC item involved in the operation.
propertyIdArray
Array of Property IDs being obtained

Return Value

The function returns an array of OpcLabs.BaseLib.OperationModel.ValueResult objects. The indices of elements in the output array are the same as those in the input array.
Exceptions
ExceptionDescription
A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
Remarks

This method does not throw an exception in case of OPC operation failures. Instead, the eventual exception related to each property is returned in Exception property of each returned OpcLabs.BaseLib.OperationModel.ValueResult element.

 

This is a multiple-operation method. In a properly written program, it does not throw any exceptions. You should therefore not put try/catch statements or similar constructs around calls to this method. The only exceptions thrown by this method are for usage errors, i.e. when your code violates the usage contract of the method, such as passing in invalid arguments or calling the method when the state of the object does not allow it. Any operation-related errors (i.e. errors that depend on external conditions that your code cannot reliably check) are indicated in the result objects returned by the method. For more information, see Multiple-operation Methods and Do not catch any exceptions with asynchronous or multiple-operation methods.
Example
// This example shows how to get value of multiple OPC properties, and handle errors.
//
// Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
// case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run 
// IEasyDAClient.ReadMultipleItemValues.Main.vbs shortly before this example, in order to obtain better property values. Your 
// code may also subscribe to the items in order to assure that they remain active.

using System;
using OpcLabs.BaseLib.OperationModel;
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    partial class GetMultiplePropertyValues
    {
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            ServerDescriptor serverDescriptor = "OPCLabs.KitServer.2";

            // Get the values of Timestamp and AccessRights properties of two items.
            ValueResult[] results = client.GetMultiplePropertyValues(new[]
            {
                new DAPropertyArguments(serverDescriptor, "Simulation.Random", DAPropertyDescriptor.Timestamp),
                new DAPropertyArguments(serverDescriptor, "Simulation.Random", DAPropertyDescriptor.AccessRights),
                new DAPropertyArguments(serverDescriptor, "Trends.Ramp (1 min)", DAPropertyDescriptor.Timestamp),
                new DAPropertyArguments(serverDescriptor, "Trends.Ramp (1 min)", DAPropertyDescriptor.AccessRights)
            });

            for (int i = 0; i < results.Length; i++)
            {
                ValueResult valueResult = results[i];
                if (valueResult.Exception is null)
                    Console.WriteLine($"results({i}).Value: {valueResult.Value}");
                else
                    Console.WriteLine($"results({i}).Exception.Message: {valueResult.Exception.Message}");
            }
        }
    }
}
# This example shows how to get value of multiple OPC properties, and handle errors.
#
# Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
# case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run 
# IEasyDAClient.ReadMultipleItemValues.Main.vbs shortly before this example, in order to obtain better property values. Your 
# code may also subscribe to the items in order to assure that they remain active.

#requires -Version 5.1
using namespace OpcLabs.EasyOpc.OperationModel
using namespace OpcLabs.EasyOpc
using namespace OpcLabs.EasyOpc.DataAccess
using namespace OpcLabs.EasyOpc.DataAccess.OperationModel

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Assemblies/net47/OpcLabs.EasyOpcClassic.dll"

# Instantiate the client object.
$client = New-Object EasyDAClient

$serverDescriptor = New-Object ServerDescriptor("OPCLabs.KitServer.2")

# Get the values of Timestamp and AccessRights properties of two items.
$results = $client.GetMultiplePropertyValues(@(
    (New-Object DAPropertyArguments($serverDescriptor, "Simulation.Random", [DAPropertyDescriptor]::Timestamp)),
    (New-Object DAPropertyArguments($serverDescriptor, "Simulation.Random", [DAPropertyDescriptor]::AccessRights)),
    (New-Object DAPropertyArguments($serverDescriptor, "Trends.Ramp (1 min)", [DAPropertyDescriptor]::Timestamp)),
    (New-Object DAPropertyArguments($serverDescriptor, "Trends.Ramp (1 min)", [DAPropertyDescriptor]::AccessRights))
    ))

for ($i = 0; $i -lt $results.Length; $i++) {
    $valueResult = $results[$i]
    if ($valueResult.Exception -eq $null) {
        Write-Host "results($($i)).Value: $($valueResult.Value)"
    }
    else {
        Write-Host "results($($i)).Exception.Message: $($valueResult.Exception.Message)"
    }
}
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2012, Windows Server 2016; .NET Core, .NET 5, .NET 6: Linux, macOS, Microsoft Windows

See Also

Reference

IEasyDAClientExtension Class
IEasyDAClientExtension Members
Overload List